package com.github.tj123.frame.service.impl;

import com.github.tj123.frame.common.page.PageRequest;
import com.github.tj123.frame.common.page.PageResponse;
import com.github.tj123.frame.common.page.PageUtils;
import com.github.tj123.frame.mapper.SDepMapper;
import com.github.tj123.frame.pojo.po.SDepPo;
import com.github.tj123.frame.service.SDepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SDepServiceImpl implements SDepService {

    @Autowired
    private SDepMapper mapper;

    @Override
    public PageResponse<Map<String, Object>> list(PageRequest request) throws Exception {
        return PageUtils.query(request, () -> mapper.list(request));
    }

    @Override
    public PageResponse<SDepPo> list2(PageRequest request) throws Exception {
        return PageUtils.query(request, () -> mapper.selectAll());
    }

    @Override
    public void add(SDepPo po) throws Exception {
        mapper.insert(po);
    }

    @Override
    public void edit(SDepPo po) throws Exception {
        mapper.updateByPrimaryKeySelective(po);
    }

    @Override
    public void del(String id) throws Exception {
        mapper.deleteByPrimaryKey(id);
    }


}
